package com.hutao.medical.pojo.dto;

import java.util.Comparator;
import java.util.Date;
import java.util.regex.Pattern;

public class PrintPageDto implements Comparator<PrintPageDto> {

	private Integer printPageType;

	private String printImagePath;

	private String originalName;

	private Date createDate;
	
	private float imageRotation = 0;

	public Integer getPrintPageType() {
		return printPageType;
	}

	public void setPrintPageType(Integer printPageType) {
		this.printPageType = printPageType;
	}

	public String getPrintImagePath() {
		return printImagePath;
	}

	public void setPrintImagePath(String printImagePath) {
		this.printImagePath = printImagePath;
	}

	public String getOriginalName() {
		return originalName;
	}

	public void setOriginalName(String originalName) {
		this.originalName = originalName;
	}

	public float getImageRotation() {
		return imageRotation;
	}

	public void setImageRotation(float imageRotation) {
		this.imageRotation = imageRotation;
	}

	@Override
	public String toString() {
		return "PrintPageDto [printPageType=" + printPageType + ", printImagePath=" + printImagePath + ", createDate="
				+ createDate + "]";
	}

	/**
	 * printPageType是sortCode
	 * 
	 */
	@Override
	public int compare(PrintPageDto o1, PrintPageDto o2) {
		if (o1.getPrintPageType().equals(o2.getPrintPageType())) {
			//文件的原文件名, 小的在前, 大的在后
			if(o1.getOriginalName()!=null && o2.getOriginalName()!=null){
				if(isNumber(o1.getOriginalName()) && isNumber(o2.getOriginalName())){
					return o1.getOriginalName().compareTo(o2.getOriginalName());
				}
			}
			
			if (o1.getCreateDate() != null && o2.getCreateDate() != null) {
				return o1.getCreateDate().compareTo(o2.getCreateDate());
			}
		}
		return o1.getPrintPageType().compareTo(o2.getPrintPageType());
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	
	public  boolean isNumber(String str){
		Pattern pattern = Pattern.compile("[0-9]*");
		return pattern.matcher(str).matches();
	}
	
	

}



